package org.finalministry.gui.components;

import java.awt.Color;
import java.awt.Image;
import java.io.IOException;

import javax.swing.ImageIcon;
import javax.swing.JButton;

import org.finalministry.Main;
import org.finalministry.gui.GuiMainActionListener;

public class ImageButton extends JButton {

	private static final long serialVersionUID = -12498496701975673L;
	private Color labelColor = new Color(0, 0, 0);

	public ImageButton(String textAndActionCommand, int x, int y, int width, int height, String image,
			GuiMainActionListener guiMainActionListener) throws IOException {

		super();

		System.out.println(Main.getLocalPath());
		ImageIcon img = new ImageIcon(Main.getLocalPath() + image);
		this.setIcon(new ImageIcon(img.getImage().getScaledInstance(width, height, Image.SCALE_FAST)));
		this.setBorderPainted(false);
		this.setBounds(x, y, width, height);
		this.setBackground(ColorSchema.getBackgroundColor());
		this.setActionCommand(textAndActionCommand);
		this.addActionListener(guiMainActionListener);

	}

	public FLabel getFLabel() {
		// TODO: insert multilanguage in FLabel ...
		FLabel label = new FLabel(getActionCommand());
		label.setForeground(labelColor);
		label.setBounds(getBounds().x + (getBounds().width / 2) - label.getPreferredSize().width / 2, getBounds().y + getBounds().height, 200,
				20);
		return label;
	}

	public Color getLabelColor() {
		return labelColor;
	}

	public void setLabelColor(Color labelColor) {
		this.labelColor = labelColor;
	}

}
